// xc_lshop/distr/manage/leader/list.js
var actbill = require('../../model/distribution_team.js')

Page({
  mixins: [require('../../../../xc/mixins/basicMixin')],

  /**
   * 页面的初始数据
   */
  data: {
    modellist:[]
  },
  xcloaddata: function (options, config) {
    this.setData({
      opordernum:options.opordernum
    })
    this.getpagelist(1)
 },
  getpagelist(rest, strwhere) {
    var that = this
    if (rest == 1) {
      that.setData({
        modellist: []
      });
      if (!strwhere) {
        strwhere = {opordernum:that.data.opordernum,cid:"1"}
      }
    }
    this.setData({
      isload: true
    })
    actbill.leaderorderoffset(that, rest, strwhere).then(function (result) {
      var updatemdoel = {};
      if ((result["code"] == "over" && result["obj"]) || result["code"] == "loadmore") {
        if (rest == 1) {
          updatemdoel["modellist"] = result["obj"]["modellist"];
        } else {
          if (result["obj"]["modellist"].length > 0) {
            updatemdoel["modellist"] = that.data.modellist.concat(result["obj"]["modellist"]);
          }
        }
      }
      wx.stopPullDownRefresh();
      updatemdoel["isload"] = false
      that.setData(updatemdoel);
    })
    return;
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    this.getpagelist(-1)
  }
})